package com.wawei.seeds.services;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;

import com.wawei.seeds.model.WalnutMainEvent;
import com.wawei.seeds.utils.RetrofitNetworkService;
import com.wawei.seeds.utils.WalnutNotifyHandler;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import retrofit.RestAdapter;

/**
 *
 * Created by t27891 on 15/6/22.
 */
public class WalnutAppointmentServiceHandler implements ServiceHandler {
    private Context context;

    public WalnutAppointmentServiceHandler(Context context) {
        this.context = context;
    }

    @Override
    public void retrieveData(RestAdapter restAdapter, Bundle bundle, Handler handler, Integer handlerTag) {
        List<WalnutMainEvent> items = new ArrayList<>(0);
        WalnutMainEvent item;
        switch (handlerTag.intValue()) {
            case WalnutNotifyHandler.LOAD_NEW_ACHIEVE_DATA:
                for (int i = 0; i < 2; i++) {
                    item = new WalnutMainEvent();
                    item.AD = "http://upload.jashnname.com/UploadedFiles/Core/Images/8ae6b53a-2f23-4a61-81cd-c8d6e6058c92.jpg";
                    item.title = "淘宝架构的演化过程";
                    item.action = "分享";
                    item.available = "本月可预约5次";
                    item.publisher = "苏妲己";
                    item.publisherHeadPortrait = "http://ts3.mm.bing.net/th?q=Missy+Peregrym&w=100&h=100&c=1&rs=1&qlt=90&bw=1&bc=333333&pid=InlineBlock&mkt=en-US&adlt=moderate&t=1&mw=247";
                    item.status = "别急，等待对方确认";
                    item.role = "高级架构师";
                    item.detail = "一个粗糙的产品，无法用户看上第一眼看上，那就是失败的。男人喜欢看美女那是人性，人都喜欢美的东西，这更是人性。";
                    item.eventId = "";
                    item.value = "100个核桃";

                    items.add(item);
                }//End of mock
                break;
            case WalnutNotifyHandler.LOAD_OLD_ACHIEVE_DATA:
                for (int i = 0; i < 2; i++) {
                    item = new WalnutMainEvent();
                    item.AD = "http://skepticfreethought.com/scrapbookoftruth/wp-content/uploads/sites/18/2015/02/Beauty2.jpg";
                    item.title = "淘宝架构的演化过程";
                    item.action = "分享";
                    item.available = "本月可预约5次";
                    item.publisher = "苏妲己";
                    item.publisherHeadPortrait = "http://ts2.mm.bing.net/th?q=Jai+Courtney&w=100&h=100&c=1&rs=1&qlt=90&bw=1&bc=333333&pid=InlineBlock&mkt=en-US&adlt=moderate&t=1&mw=247";
                    item.status = "已确认：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
                    item.role = "高级架构师";
                    item.detail = "一个粗糙的产品，无法用户看上第一眼看上，那就是失败的。男人喜欢看美女那是人性，人都喜欢美的东西，这更是人性。";
                    item.eventId = "";
                    item.value = "100个核桃";

                    items.add(item);
                }//End of mock
                break;
            case WalnutNotifyHandler.INIT_ACHIEVE_DATA:
                for (int i = 0; i < 2; i++) {
                    item = new WalnutMainEvent();
                    item.AD = "http://upload.jashnname.com/UploadedFiles/Core/Images/8ae6b53a-2f23-4a61-81cd-c8d6e6058c92.jpg";
                    item.title = "淘宝架构的演化过程";
                    item.action = "分享";
                    item.available = "本月可预约5次";
                    item.publisher = "苏妲己";
                    item.publisherHeadPortrait = "http://ts1.mm.bing.net/th?q=Mary+Lynn+Rajskub&w=100&h=100&c=1&rs=1&qlt=90&bw=1&bc=333333&pid=InlineBlock&mkt=en-US&adlt=moderate&t=1&mw=247";
                    item.status = "别急，等待对方确认";
                    item.role = "高级架构师";
                    item.detail = "一个粗糙的产品，无法用户看上第一眼看上，那就是失败的。男人喜欢看美女那是人性，人都喜欢美的东西，这更是人性。";
                    item.detail = item.detail + " 一个粗糙的产品，无法用户看上第一眼看上，那就是失败的。男人喜欢看美女那是人性，人都喜欢美的东西，这更是人性。";
                    item.eventId = "";
                    item.value = "100个核桃";

                    items.add(item);
                }
                break;
            default:
                break;
        }
        RetrofitNetworkService.handleSuccess(handler, handlerTag, items.toArray());
    }
}
